var express = require('express');
var router = express.Router();

var session = require("express-session");
router.use(session({   /*注意复制代码的时候要改 app*/
  secret: 'keyboard cat',
  resave: false,
  saveUninitialized: true
}));


//引入模块
var user=require('./admin/user');
var article=require('./admin/article');
var focus=require('./admin/focus');

var login=require('./admin/login');

var index=require('./admin/index');
var Config=require('../model/config.js').config;


//判断用户有没有登录
// router.use(function(req,res,next){
//   //判断登录没有登录
//   if(req.session.userinfo){  /*已经登录*/
//     next();
//   }else{ /*没有登录*/
//    // console.log(req.url);  //注意看路由然后判断
//     //login
//
//     if(req.url=='/login' ||req.url=='/login/doLogin' ){
//       next();
//     }else{/*跳转到登录页面*/
//       res.redirect(Config.HOST+'admin/login');
//     }
//
//   }
//
// })



/* GET users listing. */
router.use('/index',index);

//配置路由加载不同的模块
router.use('/user',user);

router.use('/article',article);

router.use('/focus',focus);


router.use('/login',login);


module.exports = router;
